#!/usr/bin/env python
# vim: set filetype=python expandtab tabstop=2 shiftwidth=2 autoindent smartindent:
# -*- coding: utf-8 -*-
#
from google.appengine.ext import db
from google.appengine.api import users


class Categories(db.Expando):
  """ categories of different places data model """
  
  name    = db.StringProperty(required=True)
  subname = db.StringProperty(required=True)
  description = db.StringProperty(required=True, multiline=True)

class Place(db.Expando):
  """ a single place """
  
  name        = db.StringProperty(required=True)
  category    = db.ReferenceProperty(Categories)
  #latitude    = db.StringProperty(required=True)
  #longitude   = db.StringProperty(required=True)  
  place       = db.GeoPtProperty(required=True)
  description = db.StringProperty(required=True, multiline=True)
  
class Event(db.Expando):
  """ event happens in a place during particular time """
  
  name        = db.StringProperty(required=True)
  place       = db.ReferenceProperty(Place)
  startdate   = db.DateTimeProperty(required=True)
  stopdate    = db.DateTimeProperty(required=True)
  description = db.StringProperty(required=True, multiline=True)

def main():
  c = Categories(key_name='hotel', name=u'宾馆', subname=u'五星级宾馆', description=u'价格最低500起')
  c.put()
  
  p = Place(key_name='dachong', name=u'大冲宾馆', category=c, place="22, 114", description=u'公司对面')
  p.put()
  
  e = Event(key_name='chistmas', name=u'圣诞打折', place=p, startdate=datetime.datetime(2007, 8, 20, 10, 10), stopdate=datetime.datetime(2007, 9, 20, 10, 10), description=u'圣诞旅游打折')
  e.put()


if __name__ == '__main__':
  main()
